package jp.co.jbuy.listener;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class SessionListener implements HttpSessionListener {

	@Override
	public void sessionCreated(HttpSessionEvent event) {
		
		HttpSession session = event.getSession();
		// 实例化SessionBindingListener
		SessionBindingListener bindLsnr = new SessionBindingListener();
		// 将SessionBindingListener放入Session中进行监听
		session.setAttribute("bindLsnr", bindLsnr);
	}

	@Override
	public void sessionDestroyed(HttpSessionEvent event) {
		
		HttpSession session = event.getSession();
		// 将SessionBindingListener从Session中移除
		session.removeAttribute("bindLsnr");
	}
	
}
